﻿using System.Collections.ObjectModel;
using VisualWip.Core;
using VisualWip.Core.Columns;
using VisualWip.PresentationModel.Slots;

namespace VisualWip.PresentationModel.WorkItem
{
    public class WorkColumnViewModel : WorkColumnViewModelBase
    {
        public WorkColumnViewModel(Application application, WorkColumnBase workColumnBase,
                                   IColumnBuilder columnBuilder)
            : base(application, workColumnBase, columnBuilder)
        {
            WorkColumnBase = workColumnBase;
            Slots = new ObservableCollection<SlotViewModel>();
        }


        public ObservableCollection<SlotViewModel> Slots { get; private set; }

        protected override void OnRefreshDone()
        {
            base.OnRefreshDone();
            Update();
        }

        private void Update()
        {
            Slots.Clear();

            foreach (Slot slot in WorkColumnBase.Slots)
            {
                var slotViewModel = new SlotViewModel(slot, WorkColumnBase);
                Slots.Add(slotViewModel);
            }
        }
    }
}